package com.wanbangee.marksystem.service.imp;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.wanbangee.marksystem.dao.USubjectDao;
import com.wanbangee.marksystem.entities.USubject;
import com.wanbangee.marksystem.service.USubjectService;

@Service
public class USubjectServiceImp implements USubjectService {

	@Autowired
	private USubjectDao uSubjectDao;
	
	@Override
	public List<USubject> selectAllSubject(Integer schId) {
		List<USubject> subList = uSubjectDao.selectAllSubject(schId);
		//System.out.println("service"+subList);
		return subList;
	}

	/*@Override
	public List<USubject> selectSubjectBySubNm() {
		return uSubjectDao.selectSubjectBySubNm();
	}*/
	public int insertSubject(USubject uSubject) {
		int insertState = this.uSubjectDao.insertSubject(uSubject);
		return insertState;
	}

	@Override
	public USubject selectSubjectBysubId(int subId,Integer schId) {
		USubject uSubject = this.uSubjectDao.selectSubjectBysubId(subId,schId);
		return uSubject;
	}

	@Override
	public int updateSubject(USubject uSubject) {
		int updateSubjectState = this.uSubjectDao.updateSubject(uSubject);
		return updateSubjectState;
	}

	@Override
	public int updateSubjectStat(int subId, int subState) {
		int updateSubjectStateState = this.uSubjectDao.updateSubjectStat(subId, subState);
		return updateSubjectStateState;
	}

	@Override
	public int deleteSubject(int subId,Integer schId) {
		int deleteSubjectState = this.uSubjectDao.deleteSubject(subId,schId);
		return deleteSubjectState;
	}
	
	/**
	 * 分页查询所有学科
	 * @return
	 */
	public List<USubject> selectAllSubjectBypaging(Integer paging,Integer size,Integer schId){
		return this.uSubjectDao.selectAllSubjectBypaging((paging-1)*size, size,schId);
	}
	
	/**
	 * 根据学科名模糊查找学科
	 * @param subNm
	 * @return
	 */
	public List<USubject> selectSubjectByLikesubNm(Integer schId,String subNm){
		return this.uSubjectDao.selectSubjectByLikesubNm(schId, "%"+subNm+"%");
	}

}
